<?php

namespace Drupal\shushengyuan\Schemas;

use Drupal\s_commerce_service\Entity\SCommerceService;

/**
 * @OA\Schema(
 *   schema="OrderServiceItem",
 *   type="object",
 *   description="OrderServiceItem"
 * )
 */
class OrderServiceItem extends AbstractBaseModel {

  protected function getEntityType() {
    return 's_commerce_service';
  }

  protected function setValue() {
    if ($this->entity instanceof SCommerceService) {
      $value = [
        /**
         * @OA\Property(
         *   property="id",
         *   type="integer",
         *   description="ID",
         * ),
         */
        'id' => (int) $this->entity->id,
        /**
         * @OA\Property(
         *   property="product",
         *   type="object",
         *   description="产品项",
         *   ref="#/components/schemas/LineItemProduct"
         * ),
         */
        'product' => LineItemProduct::get($this->entity->line_item_id),
        /**
         * @OA\Property(
         *   property="type",
         *   type="integer",
         *   description="申请类型 0 仅退款 1 退货退款",
         * ),
         */
        'type' => (int) $this->entity->type,
        /**
         * @OA\Property(
         *   property="receipt",
         *   type="integer",
         *   description="货物状态 0 未收到货 1 已收到货  退货退款时必为1",
         * ),
         */
        'receipt' => (int) $this->entity->receipt,
        /**
         * @OA\Property(
         *   property="amount",
         *   type="number",
         *   description="退款金额",
         * ),
         */
        'amount' => $this->convertYuan($this->entity->amount),
        /**
         * @OA\Property(
         *   property="desc",
         *   type="string",
         *   description="退款说明",
         * ),
         */
        'desc' => (string) $this->entity->reason_desc,
        /**
         * @OA\Property(
         *   property="status",
         *   type="integer",
         *   description="状态 0 待审核 1 待退款 2 已完成 3 拒绝 4 待退货",
         * ),
         */
        'status' => (int) $this->entity->status,
        /**
         * @OA\Property(
         *   property="statusLabel",
         *   type="string",
         *   description="状态label",
         * ),
         */
        'statusLabel' => $this->entity->getStatusOptions()[$this->entity->status],
        /**
         * @OA\Property(
         *   property="info",
         *   type="string",
         *   description="当前状态信息",
         * ),
         */
        'info' => (string) '',
      ];
      $this->merge($value);
    }
  }

}
